import Data.List
import Control.Monad
import Control.Applicative
import System.IO

main = do
  nCases <- read <$> getLine
  mapM_ processCase [1..nCases]
  -- (replicateM_ nCases) processCase

processCase :: Int -> IO ()
processCase i = do
  n <- read <$> getLine :: IO Int
  line_v1 <- getLine
  line_v2 <- getLine
  let v1 = fmap read $ words line_v1 :: [Integer]
  let v2 = fmap read $ words line_v2 :: [Integer]
  let v1_sorted = sort v1
  let v2_sorted = sort v2
  let result = multList v1_sorted (reverse v2_sorted)
  putStrLn $ "Case #" ++ (show i) ++ ": " ++ (show result)

multList :: Num a => [a] -> [a] -> a
multList xs ys = foldr (+) 0 (zipWith (*) xs ys)
